﻿angular.module('ui.flot',[])
.directive('chart', function () {

    var htmlTemplate = '<div></div>';

    return {
        restrict: 'E',
        scope: {
            data: '=d',
            opts: '=o'
        },
        link: function (scope, elem, attrs) {
            var chart = null;
            scope.$watch('data', function (v) {
                if (!chart) {
                    chart = $.plot(elem, v, scope.opts);
                    elem.show();
                } else {
                    chart.setData(v);
                    chart.setupGrid();
                    chart.draw();
                }
            });
        }
    };
});
